use std::sync::{Arc, Mutex};
use crate::ltrail::linterface::InitCallback;
use std::thread;
use std::time::Duration;


pub struct VerLicense {
    pagename: String,
    appkey: String,
    time: u64,
}

impl VerLicense {
    /*初始化构建函数*/
    pub fn new(pagename: String,
               appkey: String,
               time: u64) -> Self {
        return VerLicense {
            pagename,
            appkey,
            time,
        };
    }

    pub fn verfiy(&self, call_back: Arc<Mutex<dyn InitCallback + 'static>>) {
        if self.pagename.eq("com.citc.rcs") &&
            self.appkey.eq("12581") {
            call_back.lock().unwrap().onInitResult(true, 1);
        } else {
            call_back.lock().unwrap().onInitResult(false, 2);
        }
    }

    pub fn dowload_license(&self, call_back: Arc<Mutex<dyn InitCallback + 'static>>) {
        thread::spawn(move || {
            thread::sleep(Duration::from_secs(3));
            println!("dowload_license 内部线程： {:?}", thread::current());
            call_back.lock().unwrap().onOtherResult(false, 3, String::from("value"));
            
        });
    }
}




























